package com.ruoyi.fantasy.service.impl;

import java.util.List;

import com.huanzhidadi.fantasy.bean.domain.FantasyTitle;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.fantasy.mapper.FantasyTitleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fantasy.mapper.FantasyTitlePropertyRequirementMapper;
import com.huanzhidadi.fantasy.bean.domain.FantasyTitlePropertyRequirement;
import com.ruoyi.fantasy.service.IFantasyTitlePropertyRequirementService;
import com.ruoyi.common.core.text.Convert;

/**
 * 称号属性要求Service业务层处理
 * 
 * @author wanghui
 * @date 2020-04-11
 */
@Service
public class FantasyTitlePropertyRequirementServiceImpl implements IFantasyTitlePropertyRequirementService 
{
    @Autowired
    private FantasyTitlePropertyRequirementMapper fantasyTitlePropertyRequirementMapper;

    @Autowired
    private FantasyTitleMapper fantasyTitleMapper;

    /**
     * 查询称号属性要求
     * 
     * @param id 称号属性要求ID
     * @return 称号属性要求
     */
    @Override
    public FantasyTitlePropertyRequirement selectFantasyTitlePropertyRequirementById(String id)
    {
        return fantasyTitlePropertyRequirementMapper.selectFantasyTitlePropertyRequirementById(id);
    }

    /**
     * 查询称号属性要求列表
     * 
     * @param fantasyTitlePropertyRequirement 称号属性要求
     * @return 称号属性要求
     */
    @Override
    public List<FantasyTitlePropertyRequirement> selectFantasyTitlePropertyRequirementList(FantasyTitlePropertyRequirement fantasyTitlePropertyRequirement)
    {
        return fantasyTitlePropertyRequirementMapper.selectFantasyTitlePropertyRequirementList(fantasyTitlePropertyRequirement);
    }

    /**
     * 新增称号属性要求
     * 
     * @param fantasyTitlePropertyRequirement 称号属性要求
     * @return 结果
     */
    @Override
    public int insertFantasyTitlePropertyRequirement(FantasyTitlePropertyRequirement fantasyTitlePropertyRequirement)
    {
        fantasyTitlePropertyRequirement.setCreateTime(DateUtils.getNowDate());
        return fantasyTitlePropertyRequirementMapper.insertFantasyTitlePropertyRequirement(fantasyTitlePropertyRequirement);
    }

    /**
     * 修改称号属性要求
     * 
     * @param fantasyTitlePropertyRequirement 称号属性要求
     * @return 结果
     */
    @Override
    public int updateFantasyTitlePropertyRequirement(FantasyTitlePropertyRequirement fantasyTitlePropertyRequirement)
    {
        fantasyTitlePropertyRequirement.setUpdateTime(DateUtils.getNowDate());
        return fantasyTitlePropertyRequirementMapper.updateFantasyTitlePropertyRequirement(fantasyTitlePropertyRequirement);
    }

    /**
     * 删除称号属性要求对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteFantasyTitlePropertyRequirementByIds(String ids)
    {
        return fantasyTitlePropertyRequirementMapper.deleteFantasyTitlePropertyRequirementByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除称号属性要求信息
     * 
     * @param id 称号属性要求ID
     * @return 结果
     */
    @Override
    public int deleteFantasyTitlePropertyRequirementById(String id)
    {
        return fantasyTitlePropertyRequirementMapper.deleteFantasyTitlePropertyRequirementById(id);
    }

    @Override
    public void transforData(List<FantasyTitlePropertyRequirement> list) {
        for (FantasyTitlePropertyRequirement requirement : list) {
            FantasyTitle fantasyTitle = fantasyTitleMapper.selectFantasyTitleById(requirement.getTitleId());
            if (fantasyTitle != null) {
                requirement.setTitleId(fantasyTitle.getTitle());
            }
        }
    }
}
